package com.tanhua.server.service;

import com.tanhua.model.vo.ErrorResult;
import com.tanhua.server.exception.BusinessException;
import com.tanhua.server.interceptor.UserHolder;
import com.tanhua.service.UserLocationApi;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @author げっしょく
 * @date 2021/10/31
 */
@Service
public class BaiduService {

    @DubboReference
    private UserLocationApi userLocationApi;

    //上报地理位置
    //                                   经度               纬度             地理描述
    public void saveOrUpdateAddr(Double longitude, Double latitude, String addrStr) {
        //获取当前用户id
        Long userId = UserHolder.getId();
        //调用方法保存数据
        Boolean aBoolean = userLocationApi.saveOrUpdateAddr(userId, longitude, latitude, addrStr);
        if (!aBoolean) {
            throw new BusinessException(ErrorResult.error());
        }

    }
}
